home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
util
/
Mac F2C 1.3.sit
/
Mac F2C 1.3
/
CodeWarrior Support
/
For 'Mac F2C Support'
/
F2Cmain.c
< prev
next >
Wrap
Text File
|
1995-09-17
|
4KB
|
219 lines
/* STARTUP PROCEDURE FOR TRANSLATED FORTRAN PROGRAMS */
/* IMT 9Sep95 Modified for new conditional compile mechanism */
#if ( defined(THINK_C) || defined(THINK_CPLUS) )
#define TPM_F2C
#endif
/* IMT 9Sep95 Modified for new conditional compile mechanism */
#if ( defined(SYMANTEC_C) || defined(SYMANTEC_CPLUS) )
#define SPM_F2C
#endif
/* IMT 9Sep95 Modified for new conditional compile mechanism */
#if !defined(MPW_CW_F2C) && ( defined(__MWERKS__) )
#define CW_F2C
#endif
/* IMT 9Sep95 THINK Project Manager specific includes */
#ifdef TPM_F2C
#include <console.h>
#endif
/* IMT 9Sep95 Symantec Project Manager specific includes */
#ifdef SPM_F2C
#include <console.h>
#endif
/* IMT 9Sep95 CodeWarrior specific includes */
#ifdef CW_F2C
#include <console.h>
#include <SIOUX.h>
#endif
/* IMT 9Sep95 MPW CodeWarrior specific includes */
#ifdef MPW_CW_F2C
#include <console.h>
#endif
/* IMT 9Sep95 Prototypes for new functions that add multitasking */
#if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C)
#ifdef __cplusplus
extern "C" {
#endif
void InitMultiTask( long sliceInMicroSecs );
void EndMultiTask( void );
#ifdef __cplusplus
}
#endif
#endif /* Macintosh C compilers */
/* IMT 10Sep95 Declare jump buffer used to recover from exception exits & aborts */
#if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C)
#include <setjmp.h>
#ifdef __cplusplus
extern "C" {
#endif
jmp_buf gRecoverToConsole;
#ifdef __cplusplus
}
#endif
#endif /* Macintosh C compilers */
#include "stdio.h"
#include "signal.h"
#ifndef SIGIOT
#ifdef SIGABRT
#define SIGIOT SIGABRT
#endif
#endif
#ifndef KR_headers
#include "stdlib.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef NO__STDC
#define ONEXIT onexit
extern void f_exit();
#else
#ifndef KR_headers
extern void f_exit(void);
#ifndef NO_ONEXIT
#define ONEXIT atexit
extern int atexit(void (*)(void));
#endif
#else
#ifndef NO_ONEXIT
#define ONEXIT onexit
extern void f_exit();
#endif
#endif
#endif
#ifdef KR_headers
extern void f_init(), sig_die();
extern int MAIN__();
#define Int /* int */
#else
extern void f_init(void), sig_die(char*, int);
extern int MAIN__(void);
#define Int int
#endif
static void sigfdie(Int n)
{
sig_die("Floating Exception", 1);
}
static void sigidie(Int n)
{
sig_die("IOT Trap", 1);
}
#ifdef SIGQUIT
static void sigqdie(Int n)
{
sig_die("Quit signal", 1);
}
#endif
static void sigindie(Int n)
{
sig_die("Interrupt", 0);
}
static void sigtdie(Int n)
{
sig_die("Killed", 0);
}
#ifdef SIGTRAP
static void sigtrdie(Int n)
{
sig_die("Trace trap", 1);
}
#endif
int xargc;
char **xargv;
#ifdef KR_headers
main(argc, argv) int argc; char **argv;
#else
main(int argc, char **argv)
#endif
{
/* IMT 9Sep95 Add file re-direction and command-line arguments dialog */
#if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C)
argc = ccommand( &argv );
#endif /* Macintosh C compilers */
/* IMT 14Sep95 Initialize multi-tasking code for CodeWarrior */
#if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C)
InitMultiTask( 0 );
#endif /* CodeWarrior */
xargc = argc;
xargv = argv;
signal(SIGFPE, sigfdie); /* ignore underflow, enable overflow */
#ifdef SIGIOT
signal(SIGIOT, sigidie);
#endif
#ifdef SIGTRAP
signal(SIGTRAP, sigtrdie);
#endif
#ifdef SIGQUIT
if(signal(SIGQUIT,sigqdie) == SIG_IGN)
signal(SIGQUIT, SIG_IGN);
#endif
if(signal(SIGINT, sigindie) == SIG_IGN)
signal(SIGINT, SIG_IGN);
signal(SIGTERM,sigtdie);
#ifdef pdp11
ldfps(01200); /* detect overflow as an exception */
#endif
f_init();
#ifndef NO_ONEXIT
ONEXIT(f_exit);
#endif
/* IMT 10Sep95: Set-up for returning to console from exceptional exits and aborts */
#if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C)
if ( setjmp(gRecoverToConsole) == 0 )
#endif /* Macintosh C compilers */
MAIN__();
/* IMT 10Sep95: Close out multi-tasking code for CW, SPM, TPM */
#if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C)
EndMultiTask();
puts( "\nExecution complete.\n" );
#endif /* Macintosh C compilers */
#ifdef NO_ONEXIT
f_exit();
#endif
exit(0); /* exit(0) rather than return(0) to bypass Cray bug */
return 0; /* For compilers that complain of missing return values; */
/* others will complain that this is unreachable code. */
}
#ifdef __cplusplus
}
#endif